<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			function paintingDiamond(n){
				let diamond = '';
				for (var i =1 ; i <= n ; i += 2){
					let spaces = ' '.repeat( (n-i) /2); //除二是周期
					let star = '*'.repeat(i);
					diamond += spaces + star +'\n';  
				}
				for (var i = n-2 ; i >= 1 ; i -= 2){
					let spaces = ' '.repeat((n-i)/2);
					let star = '*'.repeat(i);
					diamond += spaces + star +'\n';  
				}
				return diamond;
			}
			console.log(paintingDiamond(7));
		</script>
	</body>
</html>